import re, sys
import pyrem_strs.originedstr as rm

pattern = re.compile(sys.argv[1])

# read files
fileTable = rm.FileTable()
fileTable.read_from_directory("", 
    re.compile(".+[.]py$"), recursive=True)

# search pattern in files
matchedStrs = []
for _, ns in sorted(fileTable.iteritems()):
    for m in pattern.finditer(rm.origined_str(ns)):
        matchedStrs.append(m.group())
        
# print matches
for s in matchedStrs:
    print "%s: %s" % (s.to_row_str(), s)